import React from 'react';

const Document = ({ children, data }) => {
  return (
    <html lang="en">
    <head>
      <meta charSet="UTF-8" />
      <meta httpEquiv="X-UA-Compatible" content="IE=edge" />
      <meta name="viewport" content="width=device-width, initial-scale=1.0" />
      <title>simple-ssr</title>
    </head>
    <body>

      {/* 通过 dangerouslySetInnerHTML 渲染html字符串 */}
      <div id="root" dangerouslySetInnerHTML={{ __html: children }}></div>
      <script dangerouslySetInnerHTML={{ __html: `window.__APP_DATA=${JSON.stringify(data)}` }} />
      <script src="./build/main.js"></script></body>
    </html>
  )
}

export default Document